import { Component, OnInit } from '@angular/core';

import {Bird} from '../model/bird-model';
import {Pillar} from '../model/pillar-model';
import {BirdFlyService} from './service/bird-fly.service';

@Component({
    selector: 'bird-fly',
    templateUrl: "./bird-fly.component.html",
    styleUrls: ['./bird-fly.component.css']
})

export class BirdFlyComponent implements OnInit {
    public bird: Bird = new Bird();

    constructor(public birdFlyService: BirdFlyService
    ) {
        console.log(this.bird)
    }
    ngOnInit() {
        this.birdFlyService.init();
        this.bird = this.birdFlyService.getBird();
        let observer = data => {
            this.bird = this.birdFlyService.getBird();
        }
        this.birdFlyService.addObserver(observer);
    }
    birdFly(): void{
        this.birdFlyService.birdFly();
    }
    start(): void{
        this.birdFlyService.start();
    }

}